#include "../logs/dhylog.hpp"
#include"unistd.h"
void test_log(const std::string &name)
{
    INFO("%s", "测试开始");
    dhylog::Logger::ptr logger=dhylog::LoggerManager::getInstance().getLogger(name);
    logger->debug( "%s", "测试日志");
    logger->info( "%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->warn( "%s", "测试日志");
    logger->fatal("%s", "测试日志");
    INFO( "%s", "测试结束");
}
int main()
{
    std::unique_ptr<dhylog::LoggerBuilder> builder(new dhylog::GlobalLoggerBuilder());
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(dhylog::loglevel::value::WARN);
    builder->buildFormatter("[%c][%f:%l]%m%n");
    builder->buildLoggerType(dhylog::LoggerType::LOGGER_ASYNC);
    //builder->buildEnableUnSafeAsync();
    builder->buildSink<dhylog::FileSink>("./logfile/async.log");
    builder->buildSink<dhylog::StdoutSink>();
    builder->buildSink<dhylog::RollSink>("./logfile/roll-async-by-size",1024*1024);
    builder->build();
    test_log("async_logger");
    return 0;
}
